---
import { Image } from 'astro:assets';

export interface Props {
  title: string;
  desc: string;
  date: string;
  cover: ImageMetadata;
  tags?: { icon?: any; text: string; color?: string }[];
  href?: string;
  meta?: string;
  pin?: boolean;
}
const { title, desc, date, cover, tags = [], href, meta, pin } = Astro.props;
---

<style>
.content-card {
  display: flex;
  align-items: stretch;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.07);
  padding: 0 0 0 32px;
  margin-bottom: 32px;
  border: 1.5px solid transparent;
  gap: 0;
  min-height: 180px;
  overflow: hidden;
  margin-top: 20px;
}

.content-card-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 20px 5px 10px 0;
}

.content-card-meta {
  font-size: 1.02rem;
  color: #5a6987;
  margin-bottom: 10px;
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}
.content-card-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: #2d3559;
  margin-bottom: 8px;
  line-height: 1.2;
  transition: color 0.18s;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1.5); /* 弹性过渡曲线 */
}
.content-card-title:hover{
    color:blue;
    transform: translateY(-4px); /* 向上移动4像素 */
}
.content-card-desc {
  font-size: 1.08rem;
  color: #5a6987;
  margin-bottom: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.content-card-tags {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.content-card-tag {
  background: #e6f0ff;
  color: #0070f3;
  border-radius: 8px;
  padding: 2px 10px;
  font-size: 0.97rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.content-card-cover-wrap {
  position: relative;
  flex:1;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  border-radius:  0;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.18s;
}
.content-card-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius:  0;
  transition: transform 0.25s cubic-bezier(.4,0,.2,1);
  display: block;
}
.content-card-cover-wrap:hover .content-card-cover-img {
  transform: scale(1.05);
  filter: brightness(1.05);
}
.content-card-arrow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
  font-size: 2.8rem;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.content-card-cover-wrap:hover .content-card-arrow {
  opacity: 1;
}
</style>

<div class="content-card">
  <div class="content-card-main">
    <div class="content-card-meta">
      <span>📅 {date}</span>
      {pin && <span>📌 Pin</span>}
      {meta && <span>📖 {meta}</span>}
    </div>
    {href ? (
      <a class="content-card-title" href={href}>{title}</a>
    ) : (
      <div class="content-card-title">{title}</div>
    )}
    <div class="content-card-desc">{desc}</div>
    {tags.length > 0 && (
      <div class="content-card-tags">
        {tags.map(tag => (
          <span class="content-card-tag" style={tag.color ? `background:${tag.color}22;color:${tag.color}` : ""}>
            {tag.icon && tag.icon}
            {tag.text}
          </span>
        ))}
      </div>
    )}
  </div>
  <a class="content-card-cover-wrap" href={href}>
    <Image class="content-card-cover-img" src={cover} alt={`${title} icon`}  />
    <span class="content-card-arrow">→</span>
  </a>
</div>